home *** CD-ROM | disk | FTP | other *** search
- /*my header so I can identify my WDEF patch*/
- header()
- {
- extern pascal long main();
- asm
- {
- lea header,a0
- jmp main
- dc.b "Eric's wdef"
- }
- }
-
- #include "MacTypes.h"
- #include "MemoryMgr.h"
- #include "Quickdraw.h"
- #include "WindowMgr.h"
- #include "SetUpA4.h"
-
- #define NO 0
- #define YES 1
- #define nil 0L
- #define origID 69 /*for installer version*/
- /* #define origID 0*/ /*for init version*/
- pascal long main();
- void dohitTest(WindowPtr,long);
-
- Handle hh = nil;
-
- pascal long main(variation, whichWindow, message, parameter)
- short variation;
- WindowPtr whichWindow;
- short message;
- long parameter;
- {
- long result;
- WindowPtr savePort;
-
- RememberA0();
- SetUpA4();
-
- if ( hh == nil )
- hh = GetResource('WDEF',origID);
-
- if ( *hh == nil )
- LoadResource(hh);
-
-
- HLock(hh);
-
- asm
- {
- clr.l -(a7)
- move variation,-(a7)
- move.l whichWindow,-(a7)
- move message,-(a7)
- move.l parameter,-(a7)
-
- movea.l hh,a0
- move.l (a0),a0
- jsr (a0)
-
- move.l (a7)+,d0
- move.l d0,result
- }
-
- HUnlock(hh);
-
- if ( message == wDraw )
- {
- if ( variation == 0 ||
- variation == 4 ||
- variation == 5 ||
- variation == 8 ||
- variation == 12 )
- dowindowdraw(whichWindow,parameter);
- }
-
- if ( message == 1 && result == wInDrag && whichWindow == FrontWindow() )
- {
- GetPort(&savePort);
- SetPort(whichWindow);
- dohitTest(whichWindow,parameter);
- SetPort(savePort);
- }
-
- RestoreA4();
-
- return(result);
- }
-
- void dohitTest(theWindow,param)
- WindowPtr theWindow;
- long param;
- {
- Point hitPt;
- MenuHandle mm;
- long Result;
- DateTimeRec date;
- Str255 ts,os;
- int len = 0;
- int hour,isAM;
- WindowPeek wRec;
- Rect rr;
-
- hitPt.v = HiWord(param);
- hitPt.h = LoWord(param);
-
- wRec = (WindowPeek)theWindow;
- rr = (*(wRec->strucRgn))->rgnBBox;
-
- rr.bottom = rr.top + 15;
- rr.top += 4;
- rr.left = rr.right - 40;
- rr.right = rr.left + 11;
-
- if ( PtInRect(hitPt,&rr) )
- {
- GetTime(&date);
-
- mm = NewMenu(140,"\pmenu name");
- AppendMenu (mm,"\pToday is:");
- if ( StringWidth("\pToday is:") > len ) len = StringWidth("\pToday is:");
-
- switch(date.dayOfWeek)
- {
- case 1:
- AppendMenu (mm,"\p Sunday");
- if ( StringWidth("\p Sunday") > len )
- len = StringWidth("\p Sunday");
- break;
- case 2:
- AppendMenu (mm,"\p Monday");
- if ( StringWidth("\p Monday") > len )
- len = StringWidth("\p Monday");
- break;
- case 3:
- AppendMenu (mm,"\p Tuesday");
- if ( StringWidth("\p Tuesday") > len )
- len = StringWidth("\p Tuesday");
- break;
- case 4:
- AppendMenu (mm,"\p Wednesday");
- if ( StringWidth("\p Wednesday") > len )
- len = StringWidth("\p Wednesday");
- break;
- case 5:
- AppendMenu (mm,"\p Thursday");
- if ( StringWidth("\p Thursday") > len )
- len = StringWidth("\p Thursday");
- break;
- case 6:
- AppendMenu (mm,"\p TGI Friday");
- if ( StringWidth("\p TGI Friday") > len )
- len = StringWidth("\p TGI Friday");
- break;
- case 7:
- AppendMenu (mm,"\p Saturday");
- if ( StringWidth("\p Saturday") > len )
- len = StringWidth("\p Saturday");
- break;
- default:
- AppendMenu (mm,"\p No Such Day!");
- if ( StringWidth("\p No Such Day!") > len )
- len = StringWidth("\p No Such Day!");
- break;
- }
-
- pStrCpy((char*)os,(char*)"\p ");
- NumToString(date.month,&ts);
- pStrCat((char*)os,(char*)ts);
- pStrCat((char*)os,(char*)"\p/");
- NumToString(date.day,&ts);
- pStrCat((char*)os,(char*)ts);
- pStrCat((char*)os,(char*)"\p/");
- NumToString(date.year,&ts);
- pStrCat((char*)os,(char*)ts);
- AppendMenu (mm,"\pa");
- SetItem(mm,3,os);
- if ( StringWidth(os) > len ) len = StringWidth(os);
-
- hour = date.hour;
- if ( hour > 12 )
- {
- isAM = NO;
- hour -= 12;
- }
- else
- {
- isAM = YES;
- if ( hour == 0 )
- hour = 12;
- }
- pStrCpy((char*)os,(char*)"\p ");
- NumToString(hour,&ts);
- pRightJust((char*)ts,2);
- pStrCat((char*)os,(char*)ts);
- pStrCat((char*)os,(char*)"\p:");
- NumToString(date.minute,&ts);
- pRightJust((char*)ts,2);
- pStrCat((char*)os,(char*)ts);
- pStrCat((char*)os,(char*)"\p:");
- NumToString(date.second,&ts);
- pRightJust((char*)ts,2);
- pStrCat((char*)os,(char*)ts);
- if ( isAM == YES )
- pStrCat((char*)os,(char*)"\p AM");
- else
- pStrCat((char*)os,(char*)"\p PM");
-
- AppendMenu (mm,"\pa");
- SetItem(mm,4,os);
- if ( StringWidth(os) > len ) len = StringWidth(os);
-
- AppendMenu (mm,"\p(-");
- AppendMenu (mm,"\pWhat Day is it?");
- if ( StringWidth("\pWhat Day is it?") > len ) len = StringWidth("\pWhat Day is it?");
- AppendMenu (mm,"\pby Eric J. Hayes");
- if ( StringWidth("\pby Eric J. Hayes") > len ) len = StringWidth("\pby Eric J. Hayes");
- InsertMenu (mm,-1);
-
- hitPt.h = theWindow->portRect.right-len-25;
- hitPt.v = 0;
- LocalToGlobal(&hitPt);
- Result = PopUpMenuSelect(mm,hitPt.v,hitPt.h,1);
- DisposeMenu(mm);
- }
- }
-
- dowindowdraw(theWindow,param)
- WindowPtr theWindow;
- long param;
- {
- WindowPeek wRec;
- Rect rr;
-
- wRec = (WindowPeek)theWindow;
-
- if ( (wRec->visible == TRUE) && (wRec->hilited != FALSE) && (param == 0) )
- {
- rr = (*(wRec->strucRgn))->rgnBBox;
-
- rr.bottom = rr.top + 15;
- rr.top += 4;
- rr.left = rr.right - 40;
- rr.right = rr.left + 11;
-
- InsetRect(&rr,-1,-1);
- EraseRect(&rr);
- InsetRect(&rr,1,1);
- TextSize(9);
- TextFont(monaco);
- MoveTo(rr.left+3,rr.bottom-2);
- DrawString("\p?");
- TextSize(0);
- TextFont(0);
- FrameRect(&rr);
- }
- }
-